package mess;

import java.util.Arrays;

public class AddTwoNumbers {
    public static void main(String[] args) {
        int[] arr1 = {2,7,11,5};
        int target1 = 9;
        System.out.println(Arrays.toString(twoSum(arr1,target1)));

        int[] arr2 = {3,2,4};
        int target2 = 6;
        System.out.println(Arrays.toString(twoSum(arr2,target2)));

        int[] arr3 = {3,3};
        int target3 = 6;
        System.out.println(Arrays.toString(twoSum(arr3,target3)));

    }

    private static int[] twoSum(int[] nums, int target) {
        int[] result = new int[2];
        for (int i = 0; i < nums.length; i++) {
            int num1 = nums[i];
            int num2;
            for (int j = i + 1; j < nums.length; j++) {
                num2 = nums[j];
                if ((num1 + num2) == target){
                    result[0] = i;
                    result[1] = j;
                    return result;
                }
            }
        }
        return result;
    }
}

